<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Infotech Ltd.
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2005/10/24 22:40:22 $)
// $RCSfile: upgrade.php,v $ : $Revision: 1.4 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

// Is Tickets Module Registered?
if (in_array(MODULE_TICKETS, $registeredmodules))
{
		$_SWIFT["query"]["create"]["ticketlabels"] = "CREATE TABLE ". TABLE_PREFIX ."ticketlabels (
																		ticketlabelid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		title VARCHAR(255) NOT NULL DEFAULT '',
																		dateline INT UNSIGNED NOT NULL DEFAULT '0',
																		labeltype ENUM('public', 'private') NOT NULL DEFAULT 'public',
																		staffid INT UNSIGNED NOT NULL DEFAULT '0',
																		PRIMARY KEY (ticketlabelid),
																		KEY ticketlabels1 (labeltype, staffid)
																	);";

		$_SWIFT["query"]["create"]["ticketlabellinks"] = "CREATE TABLE ". TABLE_PREFIX ."ticketlabellinks (
																		ticketlabellinkid INT UNSIGNED NOT NULL AUTO_INCREMENT,
																		ticketlabelid INT UNSIGNED NOT NULL DEFAULT '0',
																		ticketid INT UNSIGNED NOT NULL DEFAULT '0',
																		PRIMARY KEY (ticketlabellinkid),
																		UNIQUE KEY ticketlabellinks1 (ticketlabelid, ticketid),
																		KEY ticketlabellinks2 (ticketid)
																	);";

	$_SWIFT["query"]["alter"]["ticketposts"][] = "ALTER TABLE `". TABLE_PREFIX ."ticketposts` DROP INDEX `ticketposts3`;";
	$_SWIFT["query"]["alter"]["ticketposts"][] = "ALTER TABLE `". TABLE_PREFIX ."ticketposts` ADD INDEX ticketposts3 (`creator`, `staffid`, `dateline`);";

	$_SWIFT["query"]["alter"]["tickets"][] = "ALTER TABLE `". TABLE_PREFIX ."tickets` ADD (islabeled SMALLINT(1) UNSIGNED NOT NULL DEFAULT '0', lastuserreplytime INT UNSIGNED NOT NULL DEFAULT '0');";

	$_SWIFT["query"]["alter"]["tickets"][] = "ALTER TABLE `". TABLE_PREFIX ."tickets` DROP INDEX `tickets8`;";
	$_SWIFT["query"]["alter"]["tickets"][] = "ALTER TABLE `". TABLE_PREFIX ."tickets` ADD INDEX tickets8 (`departmentid`, `ticketstatusid`, `lastuserreplytime`);";
}

upgrade_updateVersion("3.00.26");
?>